package com.yingside.net.chat1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        //端口号不能超过65535，最好不要低于1024
        ServerSocket ss = new ServerSocket(8888);

        //接收客户端的连接
        Socket socket = ss.accept();

        System.out.println(socket.getInetAddress() + ":" + socket.getPort());

        BufferedReader br = null;

        br = new BufferedReader(new InputStreamReader(
                socket.getInputStream()
        ));

        String s = null;

        while((s=br.readLine()) != null){
            System.out.println(s);
        }
    }
}
